MaxSize = 100

#定义栈

class Stack:
    def __init__(self,n = MaxSize):
        self.elem = [0]*n
        self.top = -1

    def push(self,e):
        if self.top==MaxSize-1: #栈满不进
            return False
        self.top+=1
        self.elem[self.top]=e
        return True

    def pop(self):
        if self.top==-1: #栈空不出
            return False
        self.top-=1
        return True

    def getTop(self):
        return self.elem[self.top]

    def empty(self):#判断栈是否为空
        return self.top==-1

#定义转换函数
def change(n,k):
    s = Stack()
    while n>0:
        t=n%k   #求余
        n//=k   #求商
        s.push(t)   #入栈
    while not s.empty():
        t = s.getTop()
        s.pop()
        print(t,end = "")
    print()

#调用转换函数
change(123,2)